package com.example.cloudproduct.controller;

import com.example.cloudproduct.config.RedisConfig;
import com.example.cloudproduct.feign.StorgeFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.time.ZonedDateTime;

@RestController
public class ProductController {

    @Autowired
    private StorgeFeign storgeFeign;

    @Autowired
    private RedisConfig redisConfig;

    @Value("${name}")
    private String name;

    @GetMapping("/order/{productId}")
    public String orderProduct(@PathVariable String productId) {
        return storgeFeign.storeProduct(productId);
    }

    @GetMapping("getProductInfo")
    public String getProductInfo() {
        return "这是商品的信息";
    }


    @GetMapping("getRedisConfig")
    public String getRedisConfig() {
        System.out.println("name = " + name);
        return redisConfig.toString();
    }

    @GetMapping("/product/flash/killing")
    public String flashKilling() {
        return "抢票成功";
    }

    public static void main(String[] args) {
        System.out.println(ZonedDateTime.now());
    }
}
